<template>
	<div>
		<div class="box">
			<uni-forms
				ref="form"
				:model="currentInfoData"
				validate-trigger="bind"
				:label-position="state == 'write' ? 'top' : 'left'"
				label-width="auto">
				<FromItem
					label="上牌城市"
					:required="true"
					:state="state"
					name="carLicenseCityKey">
					<ASelectUni
						:dict="{
							list: deptList.company,
							label: 'deptName',
							value: 'deptId',
						}"
						:state="state"
						v-model="currentInfoData.carLicenseCityKey"
						@change="change_carLicenseCityKey"></ASelectUni>
				</FromItem>
				<FromItem
					label="开发城市"
					:required="true"
					:state="state"
					name="carAffiliationKey">
					<ASelectUni
						:dict="{
							list: deptList.company,
							label: 'deptName',
							value: 'deptId',
						}"
						:state="state"
						v-model="currentInfoData.carAffiliationKey"
						@change="change_carAffiliationKey"></ASelectUni>
				</FromItem>
				<FromItem
					label="运营城市"
					:required="true"
					:state="state"
					name="carOperateCityVal">
					<AInput
						:state="state"
						v-model="currentInfoData.carOperateCityVal"></AInput>
				</FromItem>
				<FromItem
					label="车辆产权方"
					:required="true"
					:state="state"
					name="propertyOwner"
					v-if="details.carSourceType == '3'">
					<AInput
						v-model="currentInfoData.propertyOwner"
						:state="state"></AInput>
				</FromItem>
			</uni-forms>
		</div>
	</div>
</template>

<script>
	import * as app from '@/api/index.js';
	import * as apis from '@/api/quota/apply/api.js';
	import FromItem from '../formItem/index.vue';
	export default {
		name: '',
		components: { FromItem },
		dicts: [],
		props: {},
		inject: [
			'details_provide',
			'config_provide',
			'deptList_provide',
			'state_provide',
			'index_provide',
		],
		data() {
			return {};
		},
		computed: {
			details() {
				return this.details_provide();
			},
			config() {
				return this.config_provide();
			},
			deptList() {
				return this.deptList_provide();
			},
			state() {
				return this.state_provide();
			},
			index() {
				return this.index_provide();
			},
			currentInfoData() {
				return this.details.productList?.[this.index] ?? {};
			},
			firstInfoData() {
				return this.details.productList?.[0] ?? {};
			},
		},
		watch: {},
		filters: {},
		created() {},
		mounted() {},
		methods: {
			change_carLicenseCityKey({ val, item }) {
				let regionId = item?.regionId?.split('/');
				this.$set(
					this.currentInfoData,
					'carCalcCityKey',
					regionId?.[1],
				);
				this.$set(
					this.currentInfoData,
					'carLicenseCityVal',
					item?.deptName,
				);
			},
			change_carAffiliationKey({ val, item }) {
				this.$set(
					this.currentInfoData,
					'carAffiliationVal',
					item?.deptName,
				);
			},
		},
		beforeDestroy() {
			if (this.notEmpty(this.details?.productList?.[this.index])) {
				this._resetFields([
					{
						data: this.currentInfoData,
					},
				]);
			}
		},
	};
</script>

<style lang="scss" scoped>
	.box {
		// margin: 20rpx;
		// padding: 20rpx;
		padding-top: 20rpx;
		background-color: #fff;
		border-radius: 8rpx;
		.title {
			border-bottom: 1px solid #e9e9e9;
			font-weight: 500;
			padding-bottom: 10rpx;
			margin-bottom: 10rpx;
		}
	}
</style>
